package com.suitsoft.ut.dao.base;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springside.modules.orm.hibernate.HibernateDao;

import com.suitsoft.ut.entity.base.StudentTemp;

/**
 *
 *@author Suine
 */
@Repository
public class StudentTempDao extends HibernateDao<StudentTemp,Long>{
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private JdbcTemplate jdbcTemplate;

	/**
	 * 删除所有
	 */
	public void deleteAll(){
		String hql = "delete StudentTemp where 1=1";
		batchExecute(hql);
	}
	
	/**
	 * 临时表中的列表
	 * @return
	 */
	public List<Map<String,Object>> getImpList(){
		String sql = "SELECT ST.COLLEGE, COUNT(DEPARTMENT) D, SUM(CNT) C, SUM(OK) OK, SUM(NO) NO ";
		sql += " FROM (SELECT ST.COLLEGE,ST.DEPARTMENT,COUNT(ID) CNT,SUM(DECODE(ST.IS_CONFIRM, NULL, 0, 1)) OK,SUM(DECODE(ST.IS_CONFIRM, NULL, 1, 0)) NO FROM LW_STUDENT_TEMP ST GROUP BY ST.COLLEGE, ST.DEPARTMENT) ST ";
		sql += " GROUP BY ST.COLLEGE order by college";
		return jdbcTemplate.queryForList(sql);
	}
}

